/*
 * @(#)FuzzyOperator.java        1.0 2000/05/09
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */


package xfuzzy.lang;

/**
 * Clase que describe un operador difuso (en general)
 * 
 * @author Francisco Jos� Moreno Velo
 *
 */
public abstract class FuzzyOperator extends ParametricFunction 
implements Cloneable {
	
	//----------------------------------------------------------------------------//
	//                            CONSTANTES P�BLICAS                             //
	//----------------------------------------------------------------------------//
	
	public final static int AND = 1;
	public final static int OR = 2;
	public final static int NOT = 3;
	public final static int ALSO = 4;
	public final static int IMP = 5;
	public final static int MOREORLESS = 6;
	public final static int VERY = 7;
	public final static int SLIGHTLY = 8;
	public final static int DEFUZMETHOD = 9;
	
	//----------------------------------------------------------------------------//
	//                             MIEMBROS PRIVADOS                              //
	//----------------------------------------------------------------------------//
	
	/**
	 * Indica que el operador toma el valor por defecto
	 */
	private boolean isdefault = false;
	
	//----------------------------------------------------------------------------//
	//                               CONSTRUCTOR                                  //
	//----------------------------------------------------------------------------//
	
	/**
	 * Constructor
	 */	
	public FuzzyOperator(String pkg, String function) {
		super(pkg, function);
	}
	
	//----------------------------------------------------------------------------//
	//                            M�TODOS P�BLICOS                                //
	//----------------------------------------------------------------------------//
	
	/**
	 * Asigna el valor del campo isdefault (funci�n por defecto)
	 */
	public void setDefault(boolean isdefault) {
		this.isdefault = isdefault;
	}
	
	/**
	 * Estudia si el objeto es la funci�n por defecto
	 */
	public boolean isDefault() {
		return this.isdefault;
	}
	
	/**
	 *  Genera la descripcion XFL3 del objeto
	 */
	public String toXfl() {
		if(isdefault) return "";
		else return getXflDescription();
	}
	
	/**
	 * Obtiene un duplicado del objeto
	 */
	public Object clone() {
		try {
			FuzzyOperator clone = (FuzzyOperator) getClass().newInstance();
			clone.set(get());
			clone.setDefault(isdefault);
			return clone;
		}
		catch (Exception e) { return null; }
	}
	
	//----------------------------------------------------------------------------//
	//                       M�TODOS P�BLICOS ABSTRACTOS                          //
	//----------------------------------------------------------------------------//
	
	/**
	 * Obtiene el c�digo Java de la funci�n
	 */
	public abstract String getJavaCode();
	
	/**
	 * Obtiene el c�digo C de la funci�n
	 */
	public abstract String getCCode();
	
	/**
	 * Obtiene el c�digo C++ de la funci�n
	 */
	public abstract String getCppCode();
	
}
